// 出口
import GLRequest from './request'
import localCache from '@/utils/cache'

const glRequest = new GLRequest({
  baseURL: process.env.VUE_APP_BASE_URL,
  timeout: Number(process.env.VUE_APP_TIME_OUT),
  interceptors: {
    requestInterceptors(config) {
      const token = localCache.getCache('token')
      if (config?.headers && token) {
        // config.headers.Authorization = `Bearer ${token}`
        config.headers.Authorization = token
      }
      return config
    },
    responseInterceptors(res) {
      return res.data
    }
  },
  // 默认是false
  showLoading: true
})

export default glRequest
